﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web;

namespace Mimas.Core.Current
{
  public static class Culture
  {
    private static string CultureSessionKey = "{AEDAD009-6E1C-456D-B367-F82E297F07A5}";

    public static CultureInfo CurrentCulture
    {
      get
      {
        CultureInfo cultureInfo;
        if (HttpContext.Current.Session[CultureSessionKey] != null)
          cultureInfo = CultureInfo.GetCultureInfo(HttpContext.Current.Session[CultureSessionKey].ToString());
        else
          cultureInfo = CultureInfo.GetCultureInfo("tr-TR");

        Thread.CurrentThread.CurrentCulture = cultureInfo;
        Thread.CurrentThread.CurrentUICulture = cultureInfo;

        return cultureInfo;

      }
      set { HttpContext.Current.Session[CultureSessionKey] = value; }
    }

    public static string ToTitleCase(string data)
    {
      return CurrentCulture.TextInfo.ToTitleCase(data.ToLower());
    }


  }
}
